<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>todoList</title>
    </head>
    <body>
        <div id="app">
            <input v-model.lazy="msg" id="msg"/>
            <input v-model.number="age" id="age"/>
            <input v-model.trim="name" id="name"/>
            <input v-model.lazy.number.trim="name" id="name"/>
        </div>
        <script src="vue.js"></script>
        <script>
        var vm = new Vue({
            el:'#app',
            data:{
                msg:'hello',
                age:18,
                name:' zhang san '
            },
            methods:{
               
            },
            computed:{
               
            },
            watch:{
                msg(newVal,oldVal){
                    console.log('msg',newVal,oldVal)
                },
                age(newVal,oldVal){
                    console.log('age',newVal,oldVal)
                },
                name:{
                    handler(newVal,oldVal){
                      console.log('name','@'+newVal+'@')
                    },
                    //如果如果在页面初次挂载的时候就执行一次，可以把这里设置为true
                    immediate:true
                }
            }
        });
    </script>
    </body>
</html>